package com.sanhe.rfmuscle.activity.work;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;

import com.menu.app.MyApp;
import com.menu.app.model.Models;
import com.menu.app.util.Utils;
import com.sanhe.rfmuscle.databinding.ActivityInfoBinding;

import me.drakeet.support.toast.ToastUtil;

public class InfoActivity extends BaseWorkActivity {

    ActivityInfoBinding binding;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityInfoBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        binding.back2.setOnClickListener(v -> finish());
        initBall(binding.frame);

        binding.msn.setOnClickListener(v -> {
            if (!Models.Companion.get().getStartEvent().getValue()) {
                ToastUtil.showShortToast(InfoActivity.this, com.menu.app.R.string.disconnect);
                return;
            }
            toSetting();
        });
    }

    private void toPwd() {
        Intent intent = new Intent(this, Pwd2Activity.class);
        startActivity(intent);
    }

    private void toSetting() {
        MyApp.getApp().setIgnore(false);
        sendTouchEvent((byte) 0, (byte) 1);
    }

    @Override
    public void finish() {
        super.finish();
        MyApp.getApp().setIgnore(true);
    }


    @Override
    protected void onResume() {
        super.onResume();
        binding.msn.setText(Utils.getMsn());
        if (Models.Companion.get().getRentEvent().getValue() == 1) {
            binding.rentLayout.setVisibility(View.VISIBLE);
            binding.rent.setText(Models.Companion.get().getPointEvent().getValue() + "");
        } else {
            binding.rentLayout.setVisibility(View.INVISIBLE);
        }
    }
}

